package c.h.a.x.s;

import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import c.h.a.m0.h;
import c.h.b.b.e.b;
import c.h.b.b.e.c;
import c.h.b.b.e.d;
import c.h.b.b.e.e;
import c.h.b.b.e.f;
import c.h.b.b.e.g;
import c.h.b.b.e.g.a;
import com.liuzh.deviceinfo.DeviceInfoApp;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/* compiled from: AppsAnalyzeDisplayItem */
public class i {
    public Context a;
    public final b b;
    public final int c;
    public final List<o> d;

    public i(int i) {
        this.a = DeviceInfoApp.c;
        this.d = new ArrayList();
        this.b = null;
        this.c = i;
    }

    public final int a(int i) {
        int[] intArray = this.a.getResources().getIntArray(2130903045);
        if (i < 0 || i >= intArray.length) {
            i = new Random().nextInt(intArray.length - 1);
        }
        return intArray[i];
    }

    public i(b bVar) {
        this.a = DeviceInfoApp.c;
        ArrayList arrayList = new ArrayList();
        this.d = arrayList;
        this.b = bVar;
        String str = "API ";
        int i;
        o oVar;
        StringBuilder g;
        List list;
        if (bVar instanceof g) {
            this.c = 1;
            g gVar = (g) bVar;
            i = 0;
            while (i < gVar.a.size()) {
                a aVar = (a) gVar.a.get(i);
                oVar = new o();
                oVar.a = this.a.getDrawable(h.b(aVar.a));
                g = c.b.a.a.a.g(str);
                g.append(aVar.a);
                oVar.b = g.toString();
                oVar.c = this.a.getString(2131690027, new Object[]{Integer.valueOf(aVar.b.size())});
                oVar.d = h.a(aVar.a);
                this.d.add(oVar);
                if (this.d.size() < 2) {
                    i++;
                } else {
                    return;
                }
            }
        } else if (bVar instanceof e) {
            this.c = 2;
            e eVar = (e) bVar;
            i = 0;
            while (i < eVar.a.size()) {
                e.a aVar2 = (e.a) eVar.a.get(i);
                oVar = new o();
                oVar.a = this.a.getDrawable(h.b(aVar2.a));
                g = c.b.a.a.a.g(str);
                g.append(aVar2.a);
                oVar.b = g.toString();
                oVar.c = this.a.getString(2131690027, new Object[]{Integer.valueOf(aVar2.b.size())});
                oVar.d = h.a(aVar2.a);
                this.d.add(oVar);
                if (this.d.size() < 2) {
                    i++;
                } else {
                    return;
                }
            }
        } else if (bVar instanceof d) {
            this.c = 4;
            d dVar = (d) bVar;
            for (String str2 : dVar.a.keySet()) {
                if (((List) dVar.a.get(str2)) != null) {
                    oVar = new o();
                    if ("system".equalsIgnoreCase(str2)) {
                        continue;
                    } else if (!TextUtils.isEmpty(str2)) {
                        try {
                            PackageManager b = DeviceInfoApp.c.b();
                            PackageInfo packageInfo = b.getPackageInfo(str2, 0);
                            oVar.a = packageInfo.applicationInfo.loadIcon(b);
                            oVar.b = packageInfo.applicationInfo.loadLabel(b).toString();
                            oVar.c = this.a.getString(2131690027, new Object[]{Integer.valueOf(list.size())});
                            oVar.d = str2;
                            if (oVar.a == null) {
                                oVar.a = this.a.getDrawable(17629184);
                            }
                            this.d.add(oVar);
                            if (this.d.size() >= 2) {
                                return;
                            }
                        } catch (NameNotFoundException unused) {
                        }
                    }
                }
            }
        } else if (bVar instanceof c) {
            this.c = 5;
            c cVar = (c) bVar;
            for (Integer num : cVar.a.keySet()) {
                if (((List) cVar.a.get(num)) != null) {
                    oVar = new o();
                    if (num.intValue() == 0) {
                        oVar.b = this.a.getString(2131690008);
                    } else if (num.intValue() == 1) {
                        oVar.b = this.a.getString(2131690011);
                    } else if (num.intValue() == 2) {
                        oVar.b = this.a.getString(2131690012);
                    } else {
                        continue;
                    }
                    oVar.a = this.a.getDrawable(2131231052);
                    oVar.c = this.a.getString(2131690027, new Object[]{Integer.valueOf(list.size())});
                    this.d.add(oVar);
                    if (this.d.size() >= 2) {
                        return;
                    }
                }
            }
        } else if (bVar instanceof f) {
            this.c = 6;
            f fVar = (f) bVar;
            for (String str22 : fVar.a.keySet()) {
                if (((List) fVar.a.get(str22)) != null) {
                    oVar = new o();
                    oVar.b = str22;
                    oVar.a = this.a.getDrawable(2131231080);
                    oVar.c = this.a.getString(2131690027, new Object[]{Integer.valueOf(list.size())});
                    this.d.add(oVar);
                    if (this.d.size() >= 2) {
                        return;
                    }
                }
            }
        } else if (bVar instanceof c.h.b.b.e.a) {
            int i2;
            int i3;
            this.c = 3;
            c.h.b.b.e.a aVar3 = (c.h.b.b.e.a) bVar;
            list = (List) aVar3.a.get(Integer.valueOf(1));
            oVar = new o();
            oVar.b = "64 bit";
            if (list == null) {
                i2 = 0;
            } else {
                i2 = list.size();
            }
            oVar.c = this.a.getString(2131690027, new Object[]{Integer.valueOf(i2)});
            Drawable drawable = this.a.getDrawable(2131230993);
            oVar.a = drawable;
            if (drawable != null) {
                oVar.a = h.w(drawable, this.a.getResources().getColor(2131099707));
            }
            arrayList.add(oVar);
            list = (List) aVar3.a.get(Integer.valueOf(2));
            List list2 = (List) aVar3.a.get(Integer.valueOf(3));
            o oVar2 = new o();
            oVar2.b = "32 bit";
            Drawable drawable2 = this.a.getDrawable(2131230992);
            oVar2.a = drawable2;
            if (drawable2 != null) {
                oVar2.a = h.w(drawable2, this.a.getResources().getColor(2131099707));
            }
            if (list == null) {
                i2 = 0;
            } else {
                i2 = list.size();
            }
            if (list2 == null) {
                i3 = 0;
            } else {
                i3 = list2.size();
            }
            i2 += i3;
            oVar2.c = this.a.getString(2131690027, new Object[]{Integer.valueOf(i2)});
            arrayList.add(oVar2);
        } else {
            StringBuilder g2 = c.b.a.a.a.g("result item 类型非法，");
            g2.append(bVar.getClass().getName());
            throw new IllegalArgumentException(g2.toString());
        }
    }
}
